clear

set more off
graph set window fontface "Times New Roman"


///set scheme plottig
/// set scheme burd
 set scheme lean2
/// set scheme cblind
/// set scheme economist
/// set scheme mrc
/// set scheme uncluttered

**** set working directory here ***** 
 
*setting global controls **** 

use "collaboration2015.dta"

global controls per_women republican party_control  polarization squire2017 house govparty dem_pres termlimits 
global controls2 per_women republican party_control  polarization squire2017 house govparty dem_pres  
global controls3 per_women n_majority_sponsors party_control  polarization squire2017 house govparty dem_pres termlimits 
global controls4  republican party_control  polarization squire2017 house govparty dem_pres termlimits 

***** table 2 - % of bills w sponsor **** 

tab any_female_sponsor
tab multiple_female_sponsor
tab bipartisan_female_sponsor 


tab any_female_sponsor if bipartisan_sponsor == 1
tab multiple_female_sponsor if bipartisan_sponsor == 1


eststo clear

**** Figure 1 ***** 


**** up for vote ***
eststo one_up: mixed up_for_vote any_female_sponsor n_sponsors $controls || year_state:
eststo multi_up: mixed up_for_vote multiple_female_sponsor  n_sponsors $controls  || year_state:
eststo bipart_up: mixed up_for_vote bipartisan_female_sponsor  n_sponsors $controls || year_state:

**** signed into law **** 

eststo one_law: mixed signed_law any_female_sponsor  n_sponsors $controls  || year_state:
eststo multi_law: mixed signed_law multiple_female_sponsor   n_sponsors $controls || year_state:
eststo bipart_law: mixed signed_law bipartisan_female_sponsor   n_sponsors $controls  || year_state:


# delimit ;
esttab using figure1table.rtf, nogap se b(%9.4f) starlevels(^ .10 * .05 ** .01 *** .001) r2(%9.4f) 
	title("Women's effect on bill success" )
	 label
	//addnote("Dependent variable")//
	compress replace;
 #delimit cr


	coefplot  (one_up \ multi_up \ bipart_up, label(Up for Vote)) (one_law \ multi_law \ bipart_law, label(Signed into Law))  ///
	||, drop(_cons  n_sponsors per_women republican party_control  polarization squire2017 house govparty dem_pres termlimits ) ///
	format(%9.3f) xlabel(,labsize(small)) ytitle("Change in probability of bill reaching stage") yline(0, lpattern(dash) lcolor(gray) lwidth(vthin)) ///
	legend(size(small)) scheme(s1mono) ysize(3)   byopts(cols(3))  title() vertical grid(between) graphregion(margin(medlarge)) ///
	yscale(range(0 .1)) ylabel(0 "0%" .02 "2%" 0.04 "4%" .06 "6%" .08 "8%" .1 "10%")
	graph save figure1_multi_bipart.gph, replace
	graph export figure1_multi_bipart.png, replace width(1800)
	
	
**** Figure 2 **** 

eststo clear 

eststo multi_up2: mixed up_for_vote multiple_female_sponsor  n_sponsors $controls  if multiple_sponsors == 1|| year_state:
eststo multi_vote2: mixed signed_law  multiple_female_sponsor   n_sponsors $controls  if multiple_sponsors == 1 || year_state:
eststo bipart_up2: mixed up_for_vote bipartisan_female_sponsor  n_sponsors $controls  if bipartisan_sponsors == 1 || year_state:
eststo bipart_vote2: mixed signed_law   bipartisan_female_sponsor  n_sponsors $controls  if bipartisan_sponsors == 1 || year_state:


# delimit ;
esttab using appendix_figure2table.rtf, nogap se b(%9.4f) starlevels(^ .10 * .05 ** .01 *** .001) r2(%9.4f) 
	title("Women's effect on bill success" )
	 label
	//addnote("Dependent variable")//
	compress replace;
 #delimit cr

 
eststo clear 

eststo multi_up2: mixed up_for_vote multiple_female_sponsor  n_sponsors $controls  if multiple_sponsors == 1|| year_state:
eststo multi_vote2: mixed signed_law  multiple_female_sponsor   n_sponsors $controls  if multiple_sponsors == 1 || year_state:
eststo bipart_up2: mixed up_for_vote bipartisan_female_sponsor  n_sponsors $controls  if bipartisan_sponsors == 1 || year_state:
eststo bipart_vote2: mixed signed_law   bipartisan_female_sponsor  n_sponsors $controls  if bipartisan_sponsors == 1 || year_state:


	
	coefplot (multi_up2 \ bipart_up2, label(Up for Vote)) (multi_vote2 \ bipart_vote2, label(Signed into Law))     ///
	||, drop(_cons  n_sponsors per_women republican party_control  polarization squire2017 house govparty dem_pres termlimits )  saving (coefplot_alt_baseline, replace)  ///
	format(%9.3f) ytitle("Change in probability of bill reaching stage") ysize(3)	xlabel(,labsize(small)) yline(0, lpattern(dash) lcolor(gray) lwidth(vthin)) ///
	legend(size(small)) scheme(s1mono)  title() vertical grid(between) graphregion(margin(medlarge)) ///
	ylabel(0 "0%" .005 ".5%" 0.01 "1%" .015 "1.5%" .02 "2%" .025 "2.5%" .03 "3%" .035 "3.5%")

graph save figure2_alt_baseline.gph, replace
graph export figure2_alt_baseline.eps, replace 
graph export figure2_alt_baseline.png, replace width(1800)


 ***** Figure 3 looking at number of women sponsors **** 
 
eststo clear

eststo n_women: xtmixed up_for_vote n_women_sponsors $controls2  || year_state:
margins, at (n_women_sponsors=(0(10)70))  atmeans post 
estimates store n_women

eststo n_men: xtmixed up_for_vote n_men_sponsors $controls2  || year_state:
margins, at (n_men_sponsors=(0(20)120)) atmeans post 
estimates store n_men 


	coefplot (n_women, label (Women)) (n_men, label (Men)), ///
	title(All Bills) ytitle("Probability of reaching floor vote") xtitle("# cosponsors") ///
	at recast(line) lwidth(*2) ciopts(recast(rline) lc(gray) lp(-) lw(vthin)) ///
	legend (rows(1) pos(6))  level(84) ///
	ylab (0 "0%" .2 "20%" .4 "40%" .6 "60%" .8 "80%" 1 "100%") ///
	ytitle ("Probability bill comes up for vote") ///
	xlab(0 25 50 75 100 125, labsize(small)) 
	graph save "up_vote_sponsors.gph", replace
	graph export "up_vote_sponsors.png", replace width(1800)


eststo n_women2: xtmixed up_for_vote n_women_bipart $controls2 || year_state:
margins, at (n_women_bipart=(0(10)50))  atmeans post 
estimates store n_women2

eststo n_men2: xtmixed up_for_vote n_men_bipart $controls2  || year_state:
margins, at (n_men_bipart=(0(25)125)) atmeans post 
estimates store n_men2


	coefplot (n_women2, label (# Women)) (n_men2, label (# Men)), ///
	title(Bipartisan bills) ytitle("") xtitle("# cosponsors") ///
	at recast(line) lwidth(*2) ciopts(recast(rline) lc(gray) lp(-) lw(vthin)) ///
	xlab(0 25 50 75 100 125, labsize(small)) ///
	ylab (0 "0%" .2 "20%" .4 "40%" .6 "60%" .8 "80%" 1 "100%") ///
	legend (rows(1) pos(6)) level(84) 
	graph save "up_vote_bipart.gph", replace
	graph export "up_vote_bipart.png", replace width(1800)


	grc1leg up_vote_sponsors.gph  up_vote_bipart.gph, scheme(s1mono) ycommon ///
	col(2) graphregion(margin(none)) ysize(3.5) 
	graph save figure3_n_sponsors.gph, replace
	graph export figure3_n_sponsors.png, replace width(1800)
	
	
# delimit ;
esttab using appendix_n_sponsors.rtf, nogap se b(%9.4f) starlevels(^ .10 * .05 ** .01 *** .001) r2(%9.4f) 
	title("Number of women and men sponsors" )
	 label nonumbers
	addnote("Dependent variable: Whether a bill makes it to a floor vote")
	compress replace;
 #delimit cr

 
 ***** Figure 3 percent women  **** 
 
 
 
eststo clear 

mixed up_for_vote  i.multiple_female_sponsor##c.per_women  n_sponsors $controls4 || year_state:
eststo multiple_no: margins, at(per_women=(0(.1).4) multiple_female_sponsors=(0)) atmeans post 
mixed up_for_vote  i.multiple_female_sponsor##c.per_women  n_sponsors $controls4 || year_state:
eststo multiple_yes: margins, at(per_women=(0(.1).4) multiple_female_sponsors=(1)) atmeans post 


	coefplot (multiple_no, label (w out multiple women)) (multiple_yes, label (w multiple women cosponsors)), ///
	ytitle ("") title("Up for Vote") legend (rows(1) pos(6)) ///
	ylab(0 "0%" .2 "20%" .4 "40%" .6 "60%", labsize(small)) ///
	xlab(0 "0%" .1 "10%" .2 "20%" .3 "30%" .4 "40%", labsize(small)) xtitle ("Share of women in the body") ///
	at recast(line) lwidth(*2)  ciopts(recast(rcap))  
	graph save "multiple_up.gph", replace
	graph export "multiple_up.png", replace width(1800)
	

eststo clear 

mixed signed_law  i.multiple_female_sponsor##c.per_women  n_sponsors $controls4 || year_state:
eststo multiple_no: margins, at(per_women=(0(.1).4) multiple_female_sponsors=(0)) atmeans post 
mixed signed_law  i.multiple_female_sponsor##c.per_women  n_sponsors $controls4 || year_state:
eststo multiple_yes: margins, at(per_women=(0(.1).4) multiple_female_sponsors=(1)) atmeans post 


	coefplot (multiple_no, label (w out multiple women)) (multiple_yes, label (w multiple women cosponsors)), ///
	ytitle ("") title("Signed into Law") legend (rows(1) pos(6)) ///
	ylab(0 "0%" .2 "20%" .4 "40%" .6 "60%", labsize(small)) ///
	xlab(0 "0%" .1 "10%" .2 "20%" .3 "30%" .4 "40%", labsize(small)) xtitle ("Share of women in the body") ///
	at recast(line) lwidth(*2)  ciopts(recast(rcap))  
	graph save "multiple_vote.gph", replace
	graph export "multiple_vote.png", replace width(1800)
	
	eststo clear 
		
	mixed up_for_vote  i.multiple_female_sponsor##c.per_women  n_sponsors $controls  || year_state:
	eststo multiple_up: margins r.multiple_female_sponsors, at(per_women=(0(.1).4)) atmeans post 
	marginsplot, title("") recast(line) recastci(rline) /// 
	ytitle ("Effect of multiple women cosponsors on bill success", size(small)) title("Up for Vote") legend (rows(1) pos(6)) ///
	addplot(histogram per_women, bin(10) yaxis(2) yscale(alt axis(2)) ytitle("% women", axis(2) size(small)) fcolor(%10) lc(black%20)) ///
	legend(off) ///
	xlab(0 "0%" .1 "10%" .2 "20%" .3 "30%" .4 "40%", labsize(small)) xtitle ("Share of women in the body")
	graph save "multiple_per_vote.gph", replace
	graph export "multiple_per_vote.png", replace width(1800)
	
	mixed signed_law  i.multiple_female_sponsor##c.per_women  n_sponsors $controls  || year_state:
	eststo multiple_law: margins r.multiple_female_sponsors, at(per_women=(0(.1).4)) atmeans post 
	marginsplot, title("") recast(line) recastci(rline) /// 
	ytitle ("Effect of multiple women cosponsors on bill success", size(small)) title("Signed into Law") legend (rows(1) pos(6)) ///
	addplot(histogram per_women, bin(10) yaxis(2) yscale(alt axis(2)) ytitle("% women", axis(2) size(small)) fcolor(%10) lc(black%20)) ///
	legend(off) ///
	xlab(0 "0%" .1 "10%" .2 "20%" .3 "30%" .4 "40%", labsize(small)) xtitle ("Share of women in the body")
	graph save "multiple_per_law.gph", replace
	graph export "multiple_per_law.png", replace width(1800)
	
	graph combine "multiple_per_vote.gph" "multiple_per_law.gph", row(1) ycommon  graphregion(margin(none)) ysize(3.5)  
	graph save  "multiple_per_women.gph", replace
	graph export multiple_per_women.png, replace width(1800)
	


	
eststo clear 
	
eststo multi_up1: mixed up_for_vote  i.multiple_female_sponsor##c.per_women  n_sponsors $controls4 || year_state:
eststo multiple: margins multiple_female_sponsors, at(per_women=(0(.1).5)) atmeans
eststo bipart_up1: mixed up_for_vote  i.bipartisan_female_sponsor##c.per_women  n_sponsors $controls4 || year_state:
eststo multiple: margins multiple_female_sponsors, at(per_women=(0(.1).5)) atmeans
eststo multi_vote1: mixed signed_law   i.multiple_female_sponsor##c.per_women   n_sponsors $controls4  || year_state:
eststo bipart_vote1: mixed signed_law    i.bipartisan_female_sponsor##c.per_women  n_sponsors $controls4 || year_state:
	
	
# delimit ;
esttab using appendix_sharewomen.rtf, nogap se b(%9.4f) starlevels(^ .10 * .05 ** .01 *** .001) r2(%9.4f) 
	title("Women's effect on bill success by women in leadership" )
	 label
	//addnote("Dependent variable")//
	compress replace;
 #delimit cr

 
***** Figure 4 women in leadership positions ***** 



eststo clear 
	
	mixed up_for_vote  i.multiple_female_sponsor##c.per_wom_leader  n_sponsors $controls  || year_state:
	eststo multiple_up: margins r.multiple_female_sponsors, at(per_wom_leader=(0(.15).75)) atmeans post 
	marginsplot, title("") recast(line) recastci(rline) /// 
	ytitle ("Effect of multiple women cosponsors on bill success", size(small)) title("Up for Vote") legend (rows(1) pos(6)) ///
	addplot(histogram per_wom_leader, bin(10) yaxis(2) yscale(alt axis(2)) ytitle("% women leaders", axis(2) size(small)) fcolor(%10) lc(black%20)) ///
	legend(off) ///
	xlab(0 "0%" .15 "15%" .3 "30%" .45 "45%" .6 "60%" .75 "75%", labsize(small)) xtitle ("Share of women in leadership", size(small)) 
	graph save "multiple_lead_vote.gph", replace
	graph export "multiple_lead_vote.png", replace width(1800)
	
	mixed signed_law  i.multiple_female_sponsor##c.per_wom_leader  n_sponsors $controls  || year_state:
	eststo multiple_law: margins r.multiple_female_sponsors, at(per_wom_leader=(0(.15).75)) atmeans post 
	marginsplot, title("") recast(line) recastci(rline) /// 
	ytitle ("Effect of multiple women cosponsors on bill success", size(small)) title("Signed into Law") legend (rows(1) pos(6)) ///
	addplot(histogram per_wom_leader, bin(10) yaxis(2) yscale(alt axis(2)) ytitle("% women leaders", axis(2) size(small)) fcolor(%10) lc(black%20)) ///
	legend(off) ///
	xlab(0 "0%" .15 "15%" .3 "30%" .45 "45%" .6 "60%" .75 "75%", labsize(small)) xtitle ("Share of women in leadership", size (small)) 
	graph save "multiple_lead_law.gph", replace
	graph export "multiple_lead_law.png", replace width(1800)
	
	graph combine "multiple_lead_vote.gph" "multiple_lead_law.gph", row(1) ycommon  graphregion(margin(none)) ysize(3.5)  
	graph save  "multiple_lead_women.gph", replace
	graph export multiple_lead_women.png, replace width(1800)
	
	
	 
# delimit ;
esttab using appendix_leadership.rtf, nogap se b(%9.4f) starlevels(^ .10 * .05 ** .01 *** .001) r2(%9.4f) 
	title("Women's effect on bill success by women in leadership" )
	 label
	//addnote("Dependent variable")//
	compress replace;
 #delimit cr

 
 
***************************************************
************** APPENDIX ***************************
***************************************************

*** basic models no controls **** 
eststo clear

eststo one_up: mixed up_for_vote any_female_sponsor  || year_state:
eststo one_law: mixed signed_law any_female_sponsor  || year_state:

**** multiple female sponsor **** 

eststo multi_up: mixed up_for_vote multiple_female_sponsor  || year_state:
eststo multi_law: mixed signed_law multiple_female_sponsor   || year_state:
****  bipartisan female sponsor **** 

eststo bipart_up: mixed up_for_vote bipartisan_female_sponsor   || year_state:
eststo bipart_law: mixed signed_law bipartisan_female_sponsor   || year_state:
# delimit ;
esttab using appendix1basemodel.rtf, nogap se b(%9.4f) starlevels(^ .10 * .05 ** .01 *** .001) r2(%9.4f) 
	title("Women's effect on bill success" )
	 label nonumbers
	//addnote("Dependent variable")//
	compress replace;
 #delimit cr


eststo clear
*** basic models - ols **** 


eststo one_up: reg up_for_vote any_female_sponsor n_sponsors $controls
eststo multi_up: reg up_for_vote multiple_female_sponsor  n_sponsors $controls  
eststo bipart_up: reg up_for_vote bipartisan_female_sponsor  n_sponsors $controls 
eststo one_law: reg signed_law any_female_sponsor  n_sponsors $controls
eststo multi_law: reg signed_law multiple_female_sponsor   n_sponsors $controls 
eststo bipart_law: reg signed_law bipartisan_female_sponsor   n_sponsors $controls  

# delimit ;
esttab using appendix2basemodel.rtf, nogap se b(%9.4f) starlevels(^ .10 * .05 ** .01 *** .001) r2(%9.4f) 
	title("Women's effect on bill success" )
	 label nonumbers
	//addnote("Dependent variable")//
	compress replace;
 #delimit cr
 
**** basic models with majority sponsors instead of Republican sponsors *****



**** up for vote ***
eststo one_up: mixed up_for_vote any_female_sponsor n_sponsors $controls3 || year_state:
eststo multi_up: mixed up_for_vote multiple_female_sponsor  n_sponsors $controls3  || year_state:
eststo bipart_up: mixed up_for_vote bipartisan_female_sponsor  n_sponsors $controls3 || year_state:


**** signed into law **** 

eststo one_law: mixed signed_law any_female_sponsor  n_sponsors $controls3  || year_state:
eststo multi_law: mixed signed_law multiple_female_sponsor   n_sponsors $controls3 || year_state:
eststo bipart_law: mixed signed_law bipartisan_female_sponsor   n_sponsors $controls3  || year_state:


# delimit ;
esttab using appendix_majority_sponsors.rtf, nogap se b(%9.4f) starlevels(^ .10 * .05 ** .01 *** .001) r2(%9.4f) 
	title("Women's effect on bill success" )
	 label
	//addnote("Dependent variable")//
	compress replace;
 #delimit cr
